*** Calculate correlation between our primary measure of success rates and
*** alternative measures

* Housekeeping
set more off
use "$college_collapse", clear

** Generate Alternate Success Rate, adjusting for success rate of non-college goers
sum kq5_cond_parq1 if super==-9
gen success_alt1 = kq5_cond_parq1 - r(mean)
gen mr_alt1 = success_alt * par_q1


** Generate Alternate Success Rate, Percent of students who start in bottom 20% and end up in top 40%
qui gen success_alt2 = (kq5_cond_parq1 + kq4_cond_parq1)
qui gen mr_alt2 = success_alt2 * par_q1


** Generate Alternate Success Rate, Percent of students who start in bottom 40% and end up in top 40%
qui gen success_alt3 = .
qui gen mr_alt3 = mr_alt2 + (kq5_cond_parq2 + kq4_cond_parq2) * par_q2


** Generate Alternate Success Rate, Percent of students who moved up two or more income quintiles
qui gen mr_alt4 = par_q1*(kq5_cond_parq1 + kq3_cond_parq1 + kq4_cond_parq1) +  par_q2*(kq5_cond_parq2 + kq4_cond_parq2) + par_q3*(kq5_cond_parq3)

** Correlation with baseline mobility rate
pwcorr mr_kq5_pq1 mr_alt* [w=count] if super > 0

matrix corr = r(C)

qui {
clear
set obs 4

gen mr_alt = ""
gen correlation = .

replace mr_alt = "Mobility Rate Adjusted for Non-College Top-Quintile Outcome Rate" if _n == 1
replace correlation = corr[1,2] if _n == 1

replace mr_alt = "Percent of Students who start in Bottom 20% and end up in Top 40%" if _n == 2
replace correlation = corr[1,3] if _n == 2

replace mr_alt = "Percent of Students who start in Bottom 40% and end up in Top 40%" if _n == 3
replace correlation = corr[1,4] if _n == 3

replace mr_alt = "Percent of Students who moved up Two or More Income Quintiles" if _n == 4
replace correlation = corr[1,5] if _n == 4
}

export delimited "${tabs}/app_table8.csv" , replace
